home *** CD-ROM | disk | FTP | other *** search
/ Shocking The Web CD-ROM / SHOCK_CD.ISO / mac / Chapter Tutorials / CaseStudies / ch14.CSAA / csaaDrive2.dir / 00003.ls < prev    next >
Encoding:
Text File  |  1996-08-28  |  6.2 KB  |  231 lines

  1. global gTargetList, gHistory, gEyeBallChan, gVioConChan, gAlertChan, gRearViewChan, gCarByeSnd, gCarHiSnd
  2.  
  3. on honkHorn arg
  4.   global gOldVol
  5.   if arg then
  6.     set gOldVol to the volume of sound 1
  7.     sound fadeIn 1, 6
  8.     set the volume of sound 1 to 50
  9.     puppetSound("BellTone")
  10.     updateStage()
  11.   else
  12.     sound fadeOut 1, 2
  13.     updateStage()
  14.     puppetSound(0)
  15.   end if
  16. end
  17.  
  18. on doMap arg
  19.   global gTopButton, gButtonInks, gFoldChan, gOldTempo, gTopCheck, gBigMapChan, gBottomButton, gTerrainChan, gThisOne
  20.   if not arg then
  21.     set gFoldChan to the clickOn
  22.     allSprites(-1, 1, gVioConChan - 1, gVioConChan)
  23.     set the visible of sprite gFoldChan to 0
  24.     set the visible of sprite gBigMapChan to 1
  25.     updateStage()
  26.     puppetSprite(gVioConChan, 1)
  27.     set gBottomButton to gTopButton + count(gTargetList) - 1
  28.     allSprites(0, 1, gTopButton, gBottomButton)
  29.     allSprites(-1, 0, gTopCheck, gBottomButton)
  30.     updateStage()
  31.     set gOldTempo to the frameTempo
  32.     puppetTempo(2)
  33.     repeat with i in gTerrainChan
  34.       set the visible of sprite i to 0
  35.     end repeat
  36.     exit
  37.   else
  38.     if integerp(arg) then
  39.       set gThisOne to arg - gTopButton + 1
  40.       allSprites(0, 0, gBigMapChan, gTopCheck + count(gTargetList) - 1)
  41.       set the visible of sprite gFoldChan to 1
  42.       updateStage()
  43.       puppetTempo(gOldTempo)
  44.       setTargetPage(gThisOne)
  45.       exit
  46.     else
  47.       if arg = "configure" then
  48.         if not gTopButton then
  49.           repeat with i = 1 to 48
  50.             if the castNum of sprite i = the number of member "mapMarker" then
  51.               set gTopButton to i
  52.               exit repeat
  53.             end if
  54.             set gTopButton to 0
  55.           end repeat
  56.           repeat with j = i to 48
  57.             if the castNum of sprite j <> the number of member "mapMarker" then
  58.               set gTopCheck to j
  59.               exit repeat
  60.             end if
  61.             set gTopCheck to 0
  62.           end repeat
  63.         end if
  64.         if gTopCheck then
  65.           repeat with k = gTopButton to gTopCheck + count(gTargetList) - 1
  66.             set the visible of sprite k to 0
  67.           end repeat
  68.           updateStage()
  69.         end if
  70.       else
  71.         if arg = "animate" then
  72.           if gTopCheck then
  73.             repeat with l = gTopCheck to gTopCheck + count(gTargetList) - 1
  74.               if getPos(gHistory, getAt(gTargetList, l - gTopCheck + 1)) then
  75.                 set the visible of sprite l to 1
  76.                 next repeat
  77.               end if
  78.               set the visible of sprite l to 0
  79.             end repeat
  80.             updateStage()
  81.           end if
  82.         end if
  83.       end if
  84.     end if
  85.   end if
  86. end
  87.  
  88. on hideRearView
  89.   global gSegStart, gNextRandTime, oldVol
  90.   puppetSound(0)
  91.   set the volume of sound 1 to 255
  92.   set oldVol to the volume of sound 1
  93.   set the volume of sound 1 to 70
  94.   puppetSound(gCarByeSnd)
  95.   set fadeDur to 60
  96.   sound fadeOut 1, fadeDur
  97.   updateStage()
  98.   set the castNum of sprite gRearViewChan to the number of member "rv-b"
  99.   updateStage()
  100.   WaitForTicks(20)
  101.   set the visible of sprite gRearViewChan to 0
  102.   puppetSprite(gRearViewChan, 0)
  103.   updateStage()
  104.   set gSegStart to the ticks
  105.   set gNextRandTime to 600 + random(800)
  106. end
  107.  
  108. on animateRearView
  109.   global gShowTime, gSegStart, gNextRandTime, gBeepRand, oldVol
  110.   puppetSound(0)
  111.   if the visible of sprite gRearViewChan = 0 then
  112.     set the volume of sound 1 to 255
  113.     set oldVol to the volume of sound 1
  114.     set the volume of sound 1 to 75
  115.     puppetSprite(gRearViewChan, 1)
  116.     set the castNum of sprite gRearViewChan to the number of member "rv-b"
  117.     set the visible of sprite gRearViewChan to 1
  118.     puppetSound("honk")
  119.     updateStage()
  120.     WaitForTicks(5)
  121.     puppetSound("honk")
  122.     updateStage()
  123.     set gShowTime to the ticks
  124.     repeat while soundBusy(1)
  125.       if the mouseDown then
  126.         exit repeat
  127.       end if
  128.     end repeat
  129.     set the castNum of sprite gRearViewChan to the number of member "rv"
  130.     updateStage()
  131.   else
  132.     if not gShowTime then
  133.       set gShowTime to the ticks
  134.     end if
  135.     if (the ticks - gShowTime) > (300 + (random(60) * 10)) then
  136.       if the castNum of sprite gRearViewChan <> the number of member "rv-lTilt" then
  137.         set the castNum of sprite gRearViewChan to the castNum of sprite gRearViewChan + 1
  138.         puppetSound("honk")
  139.         updateStage()
  140.         WaitForTicks(12)
  141.         puppetSound("honk")
  142.         updateStage()
  143.         repeat while soundBusy(1)
  144.           if the mouseDown then
  145.             exit repeat
  146.           end if
  147.         end repeat
  148.         WaitForTicks(10 + random(50))
  149.       else
  150.         hideRearView()
  151.         updateStage()
  152.         set gShowTime to the ticks
  153.         return 1
  154.       end if
  155.     end if
  156.   end if
  157. end
  158.  
  159. on followEyes
  160.   repeat with i = gEyeBallChan to gEyeBallChan + 1
  161.     set realAngle to integer(getFollowAngle(i) / 60)
  162.     set nextCast to string(realAngle) & "i"
  163.     if not (the castNum of sprite i = the number of member nextCast) then
  164.       set the castNum of sprite i to the number of member nextCast
  165.     end if
  166.   end repeat
  167.   updateStage()
  168. end
  169.  
  170. on checkMapRolz
  171.   global gTopButton, gBottomButton
  172.   repeat with i = gTopButton to gBottomButton
  173.     if rollOver(i) then
  174.       if the castNum of sprite gVioConChan <> (41 + i - gTopButton) then
  175.         set the castNum of sprite gVioConChan to 41 + i - gTopButton
  176.         updateStage()
  177.       end if
  178.       exit
  179.     end if
  180.   end repeat
  181. end
  182.  
  183. on warn
  184.   global returnDown
  185.   puppetSound(0)
  186.   allSprites(-1, 1, getAt(gAlertChan, 1), getLast(gAlertChan))
  187.   updateStage()
  188.   set rVal to 1
  189.   repeat while 1
  190.     if the key = RETURN then
  191.       set rVal to 1
  192.       exit repeat
  193.     end if
  194.     if the mouseDown then
  195.       if rollOver(getAt(gAlertChan, 2)) then
  196.         set rVal to 1
  197.         exit repeat
  198.         next repeat
  199.       end if
  200.       if rollOver(getAt(gAlertChan, 3)) then
  201.         set rVal to 0
  202.         exit repeat
  203.         next repeat
  204.       end if
  205.       nothing()
  206.     end if
  207.   end repeat
  208.   set the ink of sprite (getAt(gAlertChan, 2) + not rVal) to 6
  209.   updateStage()
  210.   WaitForTicks(8)
  211.   set the ink of sprite (getAt(gAlertChan, 2) + not rVal) to 8
  212.   allSprites(-1, 0, getAt(gAlertChan, 1), getLast(gAlertChan))
  213.   return rVal
  214. end
  215.  
  216. on keyDown
  217.   global returnDown
  218.   if the key = RETURN then
  219.     set returnDown to 1
  220.   end if
  221.   pass()
  222. end
  223.  
  224. on keyUp
  225.   global returnDown
  226.   if returnDown then
  227.     set returnDown to 0
  228.   end if
  229.   pass()
  230. end
  231.